package com.ruoyi.project.user.kkuser.service.impl;

import java.util.List;

import com.ruoyi.project.user.usermapper.domain.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.user.kkuser.mapper.KKUserMapper;
import com.ruoyi.project.user.kkuser.domain.KKUser;
import com.ruoyi.project.user.kkuser.service.IKKUserService;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;

/**
 * 用户Service业务层处理
 *
 * @author shixiangwen
 * @date 2019-12-04
 */
@Service
@DataSource(value = DataSourceType.ACCOUNT)
public class KKUserServiceImpl implements IKKUserService {
    @Autowired
    private KKUserMapper kKUserMapper;

    /**
     * 查询用户
     *
     * @param id 用户ID
     * @return 用户
     */
    @Override
    public KKUser selectKKUserById(Long id) {
        return kKUserMapper.selectKKUserById(id);
    }

    /**
     * 查询用户列表
     *
     * @param kKUser 用户
     * @return 用户
     */
    @Override
    public List<KKUser> selectKKUserList(KKUser kKUser) {
        return kKUserMapper.selectKKUserList(kKUser);
    }

    @Override
    public KKUser queryKKUser(String appId, Long kkid) {
        KKUser query = new KKUser();
        query.setAppId(appId);
        query.setKkid(kkid);
        List<KKUser> kkUsers = kKUserMapper.selectKKUserList(query);
        if (!kkUsers.isEmpty()) {
            return kkUsers.get(0);
        }
        return null;
    }

    /**
     * 新增用户
     *
     * @param kKUser 用户
     * @return 结果
     */
    @Override
    public int insertKKUser(KKUser kKUser) {
        return kKUserMapper.insertKKUser(kKUser);
    }

    /**
     * 修改用户
     *
     * @param kKUser 用户
     * @return 结果
     */
    @Override
    public int updateKKUser(KKUser kKUser) {
        return kKUserMapper.updateKKUser(kKUser);
    }

    /**
     * 删除用户对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteKKUserByIds(String ids) {
        return kKUserMapper.deleteKKUserByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除用户信息
     *
     * @param id 用户ID
     * @return 结果
     */
    @Override
    public int deleteKKUserById(Long id) {
        return kKUserMapper.deleteKKUserById(id);
    }
}
